/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RelatorioDePedidosDialog.java
 *
 * Created on Nov 12, 2010, 1:55:20 PM
 */
package br.com.tbp.gui;

import br.com.tbp.controle.ControleRelatorio;
import br.com.tbp.exception.PersistenciaException;
import javax.swing.ButtonModel;

/**
 *
 * @author Diego Freire
 */
public class RelatorioAniversariantesDialog extends javax.swing.JDialog {

    public RelatorioAniversariantesDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(null);
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupo = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        data1 = new javax.swing.JLabel();
        separador2 = new javax.swing.JSeparator();
        janeiroRadio = new javax.swing.JRadioButton();
        fevereiroRadio = new javax.swing.JRadioButton();
        marcoRadio = new javax.swing.JRadioButton();
        abrilRadio = new javax.swing.JRadioButton();
        maioRadio = new javax.swing.JRadioButton();
        junhoRadio = new javax.swing.JRadioButton();
        julhoRadio = new javax.swing.JRadioButton();
        agostoRadio = new javax.swing.JRadioButton();
        setembroRadio = new javax.swing.JRadioButton();
        outubroRadio = new javax.swing.JRadioButton();
        novembroRadio = new javax.swing.JRadioButton();
        dezembroRadio = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        emitirButton = new javax.swing.JButton();
        fecharButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("TBP - Relatório de Aniversariantes");

        data1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/tbp/resources/bolo.png"))); // NOI18N
        data1.setText("Selecione o mês e clique para emitir a lista de aniversariantes.");

        separador2.setForeground(new java.awt.Color(153, 153, 153));

        grupo.add(janeiroRadio);
        janeiroRadio.setText("Janeiro");
        janeiroRadio.setActionCommand("1");

        grupo.add(fevereiroRadio);
        fevereiroRadio.setText("Fevereiro");
        fevereiroRadio.setActionCommand("2");

        grupo.add(marcoRadio);
        marcoRadio.setText("Março");
        marcoRadio.setActionCommand("3");

        grupo.add(abrilRadio);
        abrilRadio.setText("Abril");
        abrilRadio.setActionCommand("4");

        grupo.add(maioRadio);
        maioRadio.setText("Maio");
        maioRadio.setActionCommand("5");

        grupo.add(junhoRadio);
        junhoRadio.setText("Junho");
        junhoRadio.setActionCommand("6");

        grupo.add(julhoRadio);
        julhoRadio.setText("Julho");
        julhoRadio.setActionCommand("7");

        grupo.add(agostoRadio);
        agostoRadio.setText("Agosto");
        agostoRadio.setActionCommand("8");

        grupo.add(setembroRadio);
        setembroRadio.setText("Setembro");
        setembroRadio.setActionCommand("9");

        grupo.add(outubroRadio);
        outubroRadio.setText("Outubro");
        outubroRadio.setActionCommand("10");

        grupo.add(novembroRadio);
        novembroRadio.setText("Novembro");
        novembroRadio.setActionCommand("11");

        grupo.add(dezembroRadio);
        dezembroRadio.setText("Dezembro");
        dezembroRadio.setActionCommand("12");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(separador2, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE)
                    .addComponent(data1)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(maioRadio)
                            .addComponent(marcoRadio)
                            .addComponent(abrilRadio)
                            .addComponent(fevereiroRadio)
                            .addComponent(janeiroRadio)
                            .addComponent(junhoRadio))
                        .addGap(230, 230, 230)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(dezembroRadio, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
                            .addComponent(julhoRadio, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
                            .addComponent(agostoRadio, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
                            .addComponent(outubroRadio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
                            .addComponent(novembroRadio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(setembroRadio, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(data1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(janeiroRadio)
                    .addComponent(julhoRadio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fevereiroRadio)
                    .addComponent(agostoRadio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(marcoRadio)
                    .addComponent(setembroRadio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(abrilRadio)
                    .addComponent(outubroRadio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(maioRadio)
                    .addComponent(novembroRadio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(junhoRadio)
                    .addComponent(dezembroRadio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(separador2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        emitirButton.setMnemonic('e');
        emitirButton.setText("Emitir");
        emitirButton.setPreferredSize(new java.awt.Dimension(100, 26));
        emitirButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                emitirButtonActionPerformed(evt);
            }
        });
        jPanel2.add(emitirButton);

        fecharButton.setMnemonic('f');
        fecharButton.setText("Fechar");
        fecharButton.setPreferredSize(new java.awt.Dimension(100, 26));
        fecharButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fecharButtonActionPerformed(evt);
            }
        });
        jPanel2.add(fecharButton);

        getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void emitirButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emitirButtonActionPerformed
        try {
            ButtonModel radio = grupo.getSelection();
            if (radio == null) {
                return;
            }
            int mes = Integer.parseInt(radio.getActionCommand());
            ControleRelatorio.listaAniversariantes(mes);
        } catch (PersistenciaException pex) {
            System.out.println(pex.getMessage());
        }
}//GEN-LAST:event_emitirButtonActionPerformed

    private void fecharButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fecharButtonActionPerformed
        dispose();
}//GEN-LAST:event_fecharButtonActionPerformed
    // <editor-fold defaultstate="collapsed" desc="Declaration of class members">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton abrilRadio;
    private javax.swing.JRadioButton agostoRadio;
    private javax.swing.JLabel data1;
    private javax.swing.JRadioButton dezembroRadio;
    private javax.swing.JButton emitirButton;
    private javax.swing.JButton fecharButton;
    private javax.swing.JRadioButton fevereiroRadio;
    private javax.swing.ButtonGroup grupo;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JRadioButton janeiroRadio;
    private javax.swing.JRadioButton julhoRadio;
    private javax.swing.JRadioButton junhoRadio;
    private javax.swing.JRadioButton maioRadio;
    private javax.swing.JRadioButton marcoRadio;
    private javax.swing.JRadioButton novembroRadio;
    private javax.swing.JRadioButton outubroRadio;
    private javax.swing.JSeparator separador2;
    private javax.swing.JRadioButton setembroRadio;
    // End of variables declaration//GEN-END:variables
    // </editor-fold> 
}
